package com.ruoyi.web.controller.notification;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.notification.domain.NotificationSmsLog;
import com.ruoyi.notification.service.INotificationSmsLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 短信通知日志Controller
 *
 * @author Darwin
 * @date 2024-10-08
 */
@RestController
@RequestMapping("/notification/log")
public class NotificationSmsLogController extends BaseController
{
    @Autowired
    private INotificationSmsLogService notificationSmsLogService;

    /**
     * 查询短信通知日志列表
     */
    @PreAuthorize("@ss.hasPermi('notification:log:list')")
    @RequestMapping("/list")
    public TableDataInfo list(NotificationSmsLog notificationSmsLog)
    {
        System.out.println(notificationSmsLog.getSearchStartCreated());
        startPage();
        List<NotificationSmsLog> list = notificationSmsLogService.selectNotificationSmsLogList(notificationSmsLog);
        return getDataTable(list);
    }

    /**
     * 导出短信通知日志列表
     */
    @PreAuthorize("@ss.hasPermi('notification:log:export')")
    @Log(title = "短信通知日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NotificationSmsLog notificationSmsLog)
    {
        List<NotificationSmsLog> list = notificationSmsLogService.selectNotificationSmsLogList(notificationSmsLog);
        ExcelUtil<NotificationSmsLog> util = new ExcelUtil<NotificationSmsLog>(NotificationSmsLog.class);
        util.exportExcel(response, list, "短信通知日志数据");
    }

    /**
     * 获取短信通知日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('notification:log:query')")
    @GetMapping(value = "/{uuid}")
    public AjaxResult getInfo(@PathVariable("uuid") String uuid)
    {
        return success(notificationSmsLogService.selectNotificationSmsLogByUuid(uuid));
    }

    /**
     * 新增短信通知日志
     */
    @PreAuthorize("@ss.hasPermi('notification:log:add')")
    @Log(title = "短信通知日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NotificationSmsLog notificationSmsLog)
    {
        return toAjax(notificationSmsLogService.insertNotificationSmsLog(notificationSmsLog));
    }

    /**
     * 修改短信通知日志
     */
    @PreAuthorize("@ss.hasPermi('notification:log:edit')")
    @Log(title = "短信通知日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NotificationSmsLog notificationSmsLog)
    {
        return toAjax(notificationSmsLogService.updateNotificationSmsLog(notificationSmsLog));
    }

    /**
     * 删除短信通知日志
     */
    @PreAuthorize("@ss.hasPermi('notification:log:remove')")
    @Log(title = "短信通知日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{uuids}")
    public AjaxResult remove(@PathVariable String[] uuids)
    {
        return toAjax(notificationSmsLogService.deleteNotificationSmsLogByUuids(uuids));
    }
}
